<?php

class Application_Model_DbTable_Report extends Zend_Db_Table_Abstract {

    public function getUserCount($day) {
        $db = $this->getAdapter();
        switch ($day) {
            case 2: {
                    $sql = "select count(id) userNum from uuch_user
	where DATE_FORMAT(datecreated, '%Y-%m-%e')=date_sub(curdate(),interval 2 day)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }
            case 1: {
                    $sql = "select  count(id) userNum from uuch_user
	where DATE_FORMAT(datecreated, '%Y-%m-%e')=date_sub(curdate(),interval 1 day)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }
            case 0: {
                    $sql = "select  count(id) userNum  from uuch_user
	where DATE_FORMAT(datecreated, '%Y-%m-%e')=curdate()";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }
            case 9: {
                    $sql = "select count(id)/7 userNum from uuch_user where datecreated<=date_add(curdate(),interval -2 day) and 
	datecreated>date_add(curdate(),interval -9 day) ";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }
            case 8: {
                    $sql = "select count(id)/7 userNum from uuch_user where datecreated<=date_add(curdate(),interval -1 day) and 
	datecreated>date_add(curdate(),interval -8 day) ";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }
            case 7: {
                    $sql = "select count(id)/7 userNum  from uuch_user where datecreated<=curdate() and 
	datecreated>date_add(curdate(),interval -7 day)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }
            case -7: {
                    $sql = "select count(id) userNum  from uuch_user 
                    where DATE_FORMAT(datecreated , '%Y-%m-%e')=  date_add(DATE_ADD( CURDATE( ) , INTERVAL -1
DAY ),interval -1 week)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }
            case 30: {
                    $sql = "select count(id) userNum  from uuch_user 
                    where DATE_FORMAT(datecreated , '%Y-%m-%e')=  date_add(DATE_ADD( CURDATE( ) , INTERVAL -1
DAY ),interval -1 MONTH)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }
        }
    }

    public function getStoreItemCount($day) {
        $db = $this->getAdapter();
        switch ($day) {
            case 2: {
                    $sql = "select count(id) storeitemNum from uuch_storeitem 
                    where DATE_FORMAT(dateInStore  , '%Y-%m-%e')=  date_add(curdate(),interval -2 day)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 1: {
                    $sql = "select count(id) storeitemNum from uuch_storeitem 
                    where DATE_FORMAT(dateInStore  , '%Y-%m-%e')=  date_add(curdate(),interval -1 day)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 0: {
                    $sql = "select count(id) storeitemNum from uuch_storeitem 
                    where DATE_FORMAT(dateInStore  , '%Y-%m-%e')=   curdate()";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 9: {
                    $sql = "select count(id)/7 storeitemNum from uuch_storeitem
                 where dateInStore <=date_add(curdate(),interval -2 day) and dateInStore >date_add(curdate(),interval -9 day) ";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 8: {
                    $sql = "select count(id)/7 storeitemNum from uuch_storeitem where dateInStore <=date_add(curdate(),interval -1 day) and 
	dateInStore >date_add(curdate(),interval -8 day)  ";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 7: {
                    $sql = "select count(id)/7 storeitemNum from uuch_storeitem where dateInStore <=curdate() and 
	dateInStore >date_add(curdate(),interval -7 day)  ";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case -7: {
                    $sql = "select count(id) storeitemNum  from uuch_storeitem 
                        where DATE_FORMAT(dateInStore, '%Y-%m-%e')=  date_add(DATE_ADD( CURDATE( ) , INTERVAL -1
DAY ),interval -1 week)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 30: {
                    $sql = "select count(id) storeitemNum  from uuch_storeitem 
                        where DATE_FORMAT(dateInStore, '%Y-%m-%e')=  date_add(DATE_ADD( CURDATE( ) , INTERVAL -1
DAY ),interval -1 month)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }
           case 12: {
                    $sql = "select count(id) storeitemNum from uuch_storeitem where DATE_FORMAT(dateInStore  , '%Y-%m-%e')=  date_add(curdate(),interval -2 day) 
                        and userid not in (SELECT userid from uuch_storeitem where  dateInStore <date_add(curdate(),interval -2 day)  GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 11: {
                    $sql = "select count(id) storeitemNum from uuch_storeitem where DATE_FORMAT(dateInStore  , '%Y-%m-%e')=  date_add(curdate(),interval -1 day)
                        and userid not in (SELECT userid from uuch_storeitem where  dateInStore <date_add(curdate(),interval -1 day)  GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 10: {
                    $sql = "select count(id) storeitemNum from uuch_storeitem where DATE_FORMAT(dateInStore  , '%Y-%m-%e')=   curdate()
                        and userid not in (SELECT userid from uuch_storeitem where  dateInStore < curdate()  GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 19: {
                    $sql = "select count(id)/7 storeitemNum from uuch_storeitem
                 where dateInStore <=date_add(curdate(),interval -2 day) and dateInStore >date_add(curdate(),interval -9 day) 
                 and userid not in (SELECT userid from uuch_storeitem where  dateInStore < date_add(curdate(),interval -9 day)  GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 18: {
                    $sql = "select count(id)/7 storeitemNum from uuch_storeitem where dateInStore <=date_add(curdate(),interval -1 day) and dateInStore >date_add(curdate(),interval -8 day) 
                        and userid not in (SELECT userid from uuch_storeitem where  dateInStore < date_add(curdate(),interval -8 day)  GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 17: {
                    $sql = "select count(id)/7 storeitemNum from uuch_storeitem where dateInStore <=curdate() and dateInStore >date_add(curdate(),interval -7 day)  
                        and userid not in (SELECT userid from uuch_storeitem where  dateInStore < date_add(curdate(),interval -7 day)  GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case -17: {
                    $sql = "select count(id) storeitemNum  from uuch_storeitem 
                        where DATE_FORMAT(dateInStore, '%Y-%m-%e')=  date_add(DATE_ADD( CURDATE( ) , INTERVAL -1 DAY ),interval -1 week)
                        and userid not in (SELECT userid from uuch_storeitem where  dateInStore < date_add(DATE_ADD( CURDATE( ) , INTERVAL -1 DAY ),interval -1 week)  GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 130: {
                    $sql = "select count(id) storeitemNum  from uuch_storeitem 
                        where DATE_FORMAT(dateInStore, '%Y-%m-%e')=  date_add(DATE_ADD( CURDATE( ) , INTERVAL -1 DAY ),interval -1 month)
                        and userid not in (SELECT userid from uuch_storeitem where  dateInStore < date_add(DATE_ADD( CURDATE( ) , INTERVAL -1 DAY ),interval -1 week)  GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }
           case 22: {
                    $sql = "select count(id) storeitemNum from uuch_storeitem where DATE_FORMAT(dateInStore  , '%Y-%m-%e')=  date_add(curdate(),interval -2 day) 
                        and userid  in (SELECT userid from uuch_storeitem where  dateInStore <date_add(curdate(),interval -2 day)  GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 21: {
                    $sql = "select count(id) storeitemNum from uuch_storeitem where DATE_FORMAT(dateInStore  , '%Y-%m-%e')=  date_add(curdate(),interval -1 day)
                        and userid  in (SELECT userid from uuch_storeitem where  dateInStore <date_add(curdate(),interval -1 day)  GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 20: {
                    $sql = "select count(id) storeitemNum from uuch_storeitem where DATE_FORMAT(dateInStore  , '%Y-%m-%e')=   curdate()
                        and userid  in (SELECT userid from uuch_storeitem where  dateInStore < curdate()  GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 29: {
                    $sql = "select count(id)/7 storeitemNum from uuch_storeitem
                 where dateInStore <=date_add(curdate(),interval -2 day) and dateInStore >date_add(curdate(),interval -9 day) 
                 and userid  in (SELECT userid from uuch_storeitem where  dateInStore < date_add(curdate(),interval -9 day)  GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 28: {
                    $sql = "select count(id)/7 storeitemNum from uuch_storeitem where dateInStore <=date_add(curdate(),interval -1 day) and dateInStore >date_add(curdate(),interval -8 day) 
                        and userid  in (SELECT userid from uuch_storeitem where  dateInStore < date_add(curdate(),interval -8 day)  GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 27: {
                    $sql = "select count(id)/7 storeitemNum from uuch_storeitem where dateInStore <=curdate() and dateInStore >date_add(curdate(),interval -7 day)  
                        and userid  in (SELECT userid from uuch_storeitem where  dateInStore < date_add(curdate(),interval -7 day)  GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case -27: {
                    $sql = "select count(id) storeitemNum  from uuch_storeitem 
                        where DATE_FORMAT(dateInStore, '%Y-%m-%e')=  date_add(DATE_ADD( CURDATE( ) , INTERVAL -1 DAY ),interval -1 week)
                        and userid  in (SELECT userid from uuch_storeitem where  dateInStore < date_add(DATE_ADD( CURDATE( ) , INTERVAL -1 DAY ),interval -1 week)  GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 230: {
                    $sql = "select count(id) storeitemNum  from uuch_storeitem 
                        where DATE_FORMAT(dateInStore, '%Y-%m-%e')=  date_add(DATE_ADD( CURDATE( ) , INTERVAL -1 DAY ),interval -1 month)
                        and userid in (SELECT userid from uuch_storeitem where  dateInStore < date_add(DATE_ADD( CURDATE( ) , INTERVAL -1 DAY ),interval -1 week)  GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }
        }
    }

    public function getOrderCount($day) {
        $db = $this->getAdapter();
        switch ($day) {
            case 2: {
                    $sql = "select count(id) orderNum  from uuch_order where status>=1 and DATE_FORMAT(dateCreated  , '%Y-%m-%e')=  date_add(curdate(),interval -2 day)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 1: {
                    $sql = "select count(id) orderNum  from uuch_order where status>=1 and DATE_FORMAT(dateCreated  , '%Y-%m-%e')=  date_add(curdate(),interval -1 day)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 0: {
                    $sql = "select count(id) orderNum  from uuch_order where status>=1 and DATE_FORMAT(dateCreated  , '%Y-%m-%e')=  curdate()";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 9: {
                    $sql = "select count(*)/7 from uuch_order where status>=1 and dateCreated <=date_add(curdate(),interval -2 day) and 
	dateCreated  >date_add(curdate(),interval -9 day) ";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 8: {
                    $sql = "select  count(*)/7 from uuch_order where status>=1 and dateCreated <=date_add(curdate(),interval -1 day) and 
	dateCreated  >date_add(curdate(),interval -8 day)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 7: {
                    $sql = "select count(*)/7 from uuch_order 
                        where status>=1 and dateCreated <=curdate() and 	
                        dateCreated  >date_add(curdate(),interval -7 day)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case -7: {
                    $sql = "select count(id) orderNum  from uuch_order
                    where status>=1 and DATE_FORMAT(datecreated , '%Y-%m-%e')=  date_add(DATE_ADD( CURDATE( ) , INTERVAL -1
DAY ),interval -1 week)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 30: {
                    $sql = "select count(id) orderNum  from uuch_order
                    where status>=1 and DATE_FORMAT(datecreated , '%Y-%m-%e')=  date_add(DATE_ADD( CURDATE( ) , INTERVAL -1
DAY ),interval -1 month)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }
           case 12: {
                    $sql = "select count(id) orderNum  from uuch_order where status>=1 and DATE_FORMAT(dateCreated  , '%Y-%m-%e')=  date_add(curdate(),interval -2 day)
                        and userId not in (SELECT userId from uuch_order where status>=1 and dateCreated < date_add(curdate(),interval -2 day) GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 11: {
                    $sql = "select count(id) orderNum  from uuch_order where status>=1 and DATE_FORMAT(dateCreated  , '%Y-%m-%e')=  date_add(curdate(),interval -1 day)
                        and userId not in (SELECT userId from uuch_order where status>=1 and dateCreated < date_add(curdate(),interval -1 day) GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 10: {
                    $sql = "select count(id) orderNum  from uuch_order where status>=1 and DATE_FORMAT(dateCreated  , '%Y-%m-%e')=  curdate()
                        and userId not in (SELECT userId from uuch_order where status>=1 and dateCreated < curdate() GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 19: {
                    $sql = "select count(*)/7 from uuch_order where status>=1 and dateCreated <=date_add(curdate(),interval -2 day) and 
	dateCreated  >date_add(curdate(),interval -9 day) and userId not in (SELECT userId from uuch_order where status>=1 and dateCreated < date_add(curdate(),interval -9 day) GROUP BY userid) ";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 18: {
                    $sql = "select  count(*)/7 from uuch_order where status>=1 and dateCreated <=date_add(curdate(),interval -1 day) and 
	dateCreated  >date_add(curdate(),interval -8 day) and userId not in (SELECT userId from uuch_order where status>=1 and dateCreated < date_add(curdate(),interval -8 day) GROUP BY userid) ";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 17: {
                    $sql = "select count(*)/7 from uuch_order where status>=1 and dateCreated <=curdate() and dateCreated  >date_add(curdate(),interval -7 day)
                        and userId not in (SELECT userId from uuch_order where status>=1 and dateCreated < date_add(curdate(),interval -7 day) GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case -17: {
                    $sql = "select count(id) orderNum  from uuch_order
                    where status>=1 and DATE_FORMAT(datecreated , '%Y-%m-%e')=  date_add(DATE_ADD( CURDATE( ) , INTERVAL -1 DAY ),interval -1 week)
                     and userId not in (SELECT userId from uuch_order where status>=1 and dateCreated < date_add(DATE_ADD( CURDATE( ) , INTERVAL -1 DAY ),interval -1 week) GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 130: {
                    $sql = "select count(id) orderNum  from uuch_order
                    where status>=1 and DATE_FORMAT(datecreated , '%Y-%m-%e')=  date_add(DATE_ADD( CURDATE( ) , INTERVAL -1 DAY ),interval -1 month)
                    and userId not in (SELECT userId from uuch_order where status>=1 and dateCreated < date_add(DATE_ADD( CURDATE( ) , INTERVAL -1 DAY ),interval -1 month) GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }
            case 22: {
                    $sql = "select count(id) orderNum  from uuch_order where status>=1 and DATE_FORMAT(dateCreated  , '%Y-%m-%e')=  date_add(curdate(),interval -2 day)
                        and userId in (SELECT userId from uuch_order where status>=1 and dateCreated < date_add(curdate(),interval -2 day) GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 21: {
                    $sql = "select count(id) orderNum  from uuch_order where status>=1 and DATE_FORMAT(dateCreated  , '%Y-%m-%e')=  date_add(curdate(),interval -1 day)
                        and userId in (SELECT userId from uuch_order where status>=1 and dateCreated < date_add(curdate(),interval -1 day) GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 20: {
                    $sql = "select count(id) orderNum  from uuch_order where status>=1 and DATE_FORMAT(dateCreated  , '%Y-%m-%e')=  curdate()
                        and userId in (SELECT userId from uuch_order where status>=1 and dateCreated < curdate() GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 29: {
                    $sql = "select count(*)/7 from uuch_order where status>=1 and dateCreated <=date_add(curdate(),interval -2 day) and 
	dateCreated  >date_add(curdate(),interval -9 day) and userId in (SELECT userId from uuch_order where status>=1 and dateCreated < date_add(curdate(),interval -9 day) GROUP BY userid) ";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 28: {
                    $sql = "select  count(*)/7 from uuch_order where status>=1 and dateCreated <=date_add(curdate(),interval -1 day) and 
	dateCreated  >date_add(curdate(),interval -8 day) and userId in (SELECT userId from uuch_order where status>=1 and dateCreated < date_add(curdate(),interval -8 day) GROUP BY userid) ";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 27: {
                    $sql = "select count(*)/7 from uuch_order where status>=1 and dateCreated <=curdate() and dateCreated  >date_add(curdate(),interval -7 day)
                        and userId in (SELECT userId from uuch_order where status>=1 and dateCreated < date_add(curdate(),interval -7 day) GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case -27: {
                    $sql = "select count(id) orderNum  from uuch_order
                    where status>=1 and DATE_FORMAT(datecreated , '%Y-%m-%e')=  date_add(DATE_ADD( CURDATE( ) , INTERVAL -1 DAY ),interval -1 week)
                     and userId in (SELECT userId from uuch_order where status>=1 and dateCreated < date_add(DATE_ADD( CURDATE( ) , INTERVAL -1 DAY ),interval -1 week) GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 230: {
                    $sql = "select count(id) orderNum  from uuch_order
                    where status>=1 and DATE_FORMAT(datecreated , '%Y-%m-%e')=  date_add(DATE_ADD( CURDATE( ) , INTERVAL -1 DAY ),interval -1 month)
                    and userId in (SELECT userId from uuch_order where status>=1 and dateCreated < date_add(DATE_ADD( CURDATE( ) , INTERVAL -1 DAY ),interval -1 month) GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }
        }
    }

    public function getOrderPriceCount($day) {
        $db = $this->getAdapter();
        switch ($day) {
            case 2: {
                    $sql = "select sum(sum)  from uuch_order where status>=1 and status != 10 and status != 11 and DATE_FORMAT(dateCreated  , '%Y-%m-%e')=  date_add(curdate(),interval -2 day)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 1: {
                    $sql = "select sum(sum) from uuch_order where status>=1 and status != 10 and status != 11 and DATE_FORMAT(dateCreated  , '%Y-%m-%e')=  date_add(curdate(),interval -1 day)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 0: {
                    $sql = "select sum(sum)  from uuch_order where status>=1 and status != 10 and status != 11 and DATE_FORMAT(dateCreated  , '%Y-%m-%e')=  curdate()";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 9: {
                    $sql = "select sum(sum)/7 from uuch_order where status>=1 and status != 10 and status != 11 and dateCreated <=date_add(curdate(),interval -2 day) and 
	dateCreated  >date_add(curdate(),interval -9 day) ";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 8: {
                    $sql = "select sum(sum)/7 from uuch_order where status>=1 and status != 10 and status != 11 and dateCreated <=date_add(curdate(),interval -1 day) and 
	dateCreated  >date_add(curdate(),interval -8 day)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 7: {
                    $sql = "select sum(sum)/7 from uuch_order 
                        where status>=1 and status != 10 and status != 11 and dateCreated <=curdate() and 	
                        dateCreated  >date_add(curdate(),interval -7 day)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case -7: {
                    $sql = "select sum(sum) from uuch_order
                    where status>=1 and status != 10 and status != 11 and DATE_FORMAT(datecreated , '%Y-%m-%e')=  date_add(DATE_ADD( CURDATE( ) , INTERVAL -1
DAY ),interval -1 week)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 30: {
                    $sql = "select sum(sum) from uuch_order
                    where status>=1 and status != 10 and status != 11 and DATE_FORMAT(datecreated , '%Y-%m-%e')=  date_add(DATE_ADD( CURDATE( ) , INTERVAL -1
DAY ),interval -1 month)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }
            case 12: {
                    $sql = "select sum(sum)  from uuch_order where status>=1 and status != 10 and status != 11 and DATE_FORMAT(dateCreated  , '%Y-%m-%e')=  date_add(curdate(),interval -2 day)
                        and userId not in (SELECT userId from uuch_order where status>=1 and dateCreated <date_add(curdate(),interval -2 day)  GROUP BY userid)";
                    
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 11: {
                    $sql = "select sum(sum) from uuch_order where status>=1 and status != 10 and status != 11 and DATE_FORMAT(dateCreated  , '%Y-%m-%e')=  date_add(curdate(),interval -1 day)
                        and userId not in (SELECT userId from uuch_order where status>=1 and dateCreated < date_add(curdate(),interval -1 day)  GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 10: {
                    $sql = "select sum(sum)  from uuch_order where status>=1 and  status != 10 and status != 11 and DATE_FORMAT(dateCreated  , '%Y-%m-%e')=  curdate()
                        and userId not in (SELECT userId from uuch_order where status>=1 and dateCreated <curdate()  GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 19: {
                    $sql = "select sum(sum)/7 from uuch_order where status>=1 and status != 10 and status != 11 and dateCreated <=date_add(curdate(),interval -2 day) and dateCreated  >date_add(curdate(),interval -9 day) 
                        and userId not in (SELECT userId from uuch_order where status>=1 and dateCreated <date_add(curdate(),interval -9 day)  GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 18: {
                    $sql = "select sum(sum)/7 from uuch_order where status>=1 and status != 10 and status != 11 and dateCreated <=date_add(curdate(),interval -1 day) and dateCreated  >date_add(curdate(),interval -8 day)
                       and userId not in (SELECT userId from uuch_order where status>=1 and dateCreated <date_add(curdate(),interval -8 day)  GROUP BY userid) ";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 17: {
                    $sql = "select sum(sum)/7 from uuch_order where status>=1 and status != 10 and status != 11 and dateCreated <=curdate() and dateCreated  >date_add(curdate(),interval -7 day)
                        and userId not in (SELECT userId from uuch_order where status>=1 and dateCreated <date_add(curdate(),interval -7 day)  GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case -17: {
                    $sql = "select sum(sum) from uuch_order
                    where status>=1 and status != 10 and status != 11 and DATE_FORMAT(datecreated , '%Y-%m-%e')=  date_add(DATE_ADD( CURDATE( ) , INTERVAL -1 DAY ),interval -1 week)
                    and userId not in (SELECT userId from uuch_order where status>=1 and dateCreated <date_add(DATE_ADD( CURDATE( ) , INTERVAL -1 DAY ),interval -1 week) GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 130: {
                    $sql = "select sum(sum) from uuch_order
                    where status>=1 and status != 10 and status != 11 and DATE_FORMAT(datecreated , '%Y-%m-%e')=  date_add(DATE_ADD( CURDATE( ) , INTERVAL -1 DAY ),interval -1 month)
                    and userId not in (SELECT userId from uuch_order where status>=1 and dateCreated <date_add(DATE_ADD( CURDATE( ) , INTERVAL -1 DAY ),interval -1 month) GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }
            case 22: {
                    $sql = "select sum(sum)  from uuch_order where status>=1 and status != 10 and status != 11 and DATE_FORMAT(dateCreated  , '%Y-%m-%e')=  date_add(curdate(),interval -2 day)
                        and userId in (SELECT userId from uuch_order where status>=1 and dateCreated <date_add(curdate(),interval -2 day)  GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 21: {
                    $sql = "select sum(sum) from uuch_order where status>=1 and status != 10 and status != 11 and DATE_FORMAT(dateCreated  , '%Y-%m-%e')=  date_add(curdate(),interval -1 day)
                        and userId in (SELECT userId from uuch_order where status>=1 and dateCreated <date_add(curdate(),interval -1 day)  GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 20: {
                    $sql = "select sum(sum)  from uuch_order where status>=1 and status != 10 and status != 11 and DATE_FORMAT(dateCreated  , '%Y-%m-%e')=  curdate()
                        and userId in (SELECT userId from uuch_order where status>=1 and dateCreated <curdate()  GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 29: {
                    $sql = "select sum(sum)/7 from uuch_order where status>=1 and status != 10 and status != 11 and dateCreated <=date_add(curdate(),interval -2 day) and dateCreated  >date_add(curdate(),interval -9 day) 
                        and userId in (SELECT userId from uuch_order where status>=1 and dateCreated <date_add(curdate(),interval -9 day)  GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 28: {
                    $sql = "select sum(sum)/7 from uuch_order where status>=1 and status != 10 and status != 11 and dateCreated <=date_add(curdate(),interval -1 day) and dateCreated  >date_add(curdate(),interval -8 day)
                       and userId in (SELECT userId from uuch_order where status>=1 and dateCreated <date_add(curdate(),interval -8 day)  GROUP BY userid) ";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 27: {
                    $sql = "select sum(sum)/7 from uuch_order where status>=1 and status != 10 and status != 11 and dateCreated <=curdate() and dateCreated  >date_add(curdate(),interval -7 day)
                        and userId in (SELECT userId from uuch_order where status>=1 and dateCreated <date_add(curdate(),interval -7 day)  GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case -27: {
                    $sql = "select sum(sum) from uuch_order
                    where status>=1 and status != 10 and status != 11 and DATE_FORMAT(datecreated , '%Y-%m-%e')=  date_add(DATE_ADD( CURDATE( ) , INTERVAL -1 DAY ),interval -1 week)
                    and userId in (SELECT userId from uuch_order where status>=1 and dateCreated <date_add(DATE_ADD( CURDATE( ) , INTERVAL -1 DAY ),interval -1 week) GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 230: {
                    $sql = "select sum(sum) from uuch_order
                    where status>=1 and status != 10 and status != 11 and DATE_FORMAT(datecreated , '%Y-%m-%e')=  date_add(DATE_ADD( CURDATE( ) , INTERVAL -1 DAY ),interval -1 month)
                    and userId in (SELECT userId from uuch_order where status>=1 and dateCreated <date_add(DATE_ADD( CURDATE( ) , INTERVAL -1 DAY ),interval -1 month) GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }
        }
    }

    public function getStoreItemWeightCount($day) {
        $db = $this->getAdapter();
        switch ($day) {
            case 2: {
                    $sql = "SELECT SUM(CASE WHEN isVolume=1 THEN volumeWeight ELSE productWeight+bagWeight END)/1000 FROM `uuch_waybill` 
                    where status >=1 and status >=1 and DATE_FORMAT(dateCreated  , '%Y-%m-%e')=  date_add(curdate(),interval -2 day)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 1: {
                    $sql = "SELECT SUM(CASE WHEN isVolume=1 THEN volumeWeight ELSE productWeight+bagWeight END)/1000 FROM `uuch_waybill` 
                    where status >=1 and status >=1 and DATE_FORMAT(dateCreated  , '%Y-%m-%e')=  date_add(curdate(),interval -1 day)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 0: {
                    $sql = "SELECT SUM(CASE WHEN isVolume=1 THEN volumeWeight ELSE productWeight+bagWeight END)/1000 FROM `uuch_waybill` 
                    where status >=1 and status >=1 and DATE_FORMAT(dateCreated  , '%Y-%m-%e')=   curdate()";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 9: {
                    $sql = "SELECT SUM(CASE WHEN isVolume=1 THEN volumeWeight ELSE productWeight+bagWeight END)/7000 FROM `uuch_waybill` 
                 where status >=1 and dateCreated <=date_add(curdate(),interval -2 day) and dateCreated >date_add(curdate(),interval -9 day) ";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 8: {
                    $sql = "SELECT SUM(CASE WHEN isVolume=1 THEN volumeWeight ELSE productWeight+bagWeight END)/7000 FROM `uuch_waybill` 
                 where status >=1 and dateCreated <=date_add(curdate(),interval -1 day) and dateCreated >date_add(curdate(),interval -8 day)  ";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 7: {
                    $sql = "SELECT SUM(CASE WHEN isVolume=1 THEN volumeWeight ELSE productWeight+bagWeight END)/7000 FROM `uuch_waybill` 
                 where status >=1 and dateCreated <=curdate() and dateCreated >date_add(curdate(),interval -7 day) ";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case -7: {
                    $sql = "SELECT SUM(CASE WHEN isVolume=1 THEN volumeWeight ELSE productWeight+bagWeight END)/1000 FROM uuch_waybill where status >=1 and
                        DATE_FORMAT(dateCreated, '%Y-%m-%e')=  date_add(DATE_ADD( CURDATE( ) , INTERVAL -1 DAY ),interval -1 week)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 30: {
                     $sql = "SELECT SUM(CASE WHEN isVolume=1 THEN volumeWeight ELSE productWeight+bagWeight END)/1000 FROM uuch_waybill where status >=1 and
                        DATE_FORMAT(dateCreated, '%Y-%m-%e')=  date_add(DATE_ADD( CURDATE( ) , INTERVAL -1 DAY ),interval -1 month)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }
           case 12: {
                    $sql = "SELECT SUM(CASE WHEN isVolume=1 THEN volumeWeight ELSE productWeight+bagWeight END)/1000 FROM uuch_waybill 
                    where status >=1 and status >=1 and DATE_FORMAT(dateCreated  , '%Y-%m-%e')=  date_add(curdate(),interval -2 day)
                    and userId not in (select userId from uuch_waybill where dateCreated<date_add(curdate(),interval -2 day) GROUP BY userId )";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 11: {
                    $sql = "SELECT SUM(CASE WHEN isVolume=1 THEN volumeWeight ELSE productWeight+bagWeight END)/1000 FROM `uuch_waybill` 
                    where status >=1 and DATE_FORMAT(dateCreated  , '%Y-%m-%e')=  date_add(curdate(),interval -1 day)
                    and userId not in (select userId from uuch_waybill where dateCreated<date_add(curdate(),interval -1 day) GROUP BY userId )";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 10: {
                    $sql = "SELECT SUM(CASE WHEN isVolume=1 THEN volumeWeight ELSE productWeight+bagWeight END)/1000 FROM `uuch_waybill` 
                    where status >=1 and DATE_FORMAT(dateCreated  , '%Y-%m-%e')=   curdate()
                    and userId not in (select userId from uuch_waybill where dateCreated<curdate() GROUP BY userId )";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 19: {
                    $sql = "SELECT SUM(CASE WHEN isVolume=1 THEN volumeWeight ELSE productWeight+bagWeight END)/7000 FROM `uuch_waybill` 
                 where status >=1 and dateCreated <=date_add(curdate(),interval -2 day) and dateCreated >date_add(curdate(),interval -9 day) 
                 and userId not in (select userId from uuch_waybill where dateCreated<date_add(curdate(),interval -9 day) GROUP BY userId )";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 18: {
                    $sql = "SELECT SUM(CASE WHEN isVolume=1 THEN volumeWeight ELSE productWeight+bagWeight END)/7000 FROM `uuch_waybill` 
                 where status >=1 and dateCreated <=date_add(curdate(),interval -1 day) and dateCreated >date_add(curdate(),interval -8 day)  
                 and userId not in (select userId from uuch_waybill where dateCreated<date_add(curdate(),interval -8 day) GROUP BY userId )";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 17: {
                    $sql = "SELECT SUM(CASE WHEN isVolume=1 THEN volumeWeight ELSE productWeight+bagWeight END)/7000 FROM `uuch_waybill` 
                 where status >=1 and dateCreated <=curdate() and dateCreated >date_add(curdate(),interval -7 day) 
                 and userId not in (select userId from uuch_waybill where dateCreated<date_add(curdate(),interval -7 day) GROUP BY userId )";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case -17: {
                    $sql = "SELECT SUM(CASE WHEN isVolume=1 THEN volumeWeight ELSE productWeight+bagWeight END)/1000 FROM uuch_waybill where status >=1 and
                        DATE_FORMAT(dateCreated, '%Y-%m-%e')=  date_add(DATE_ADD( CURDATE( ) , INTERVAL -1 DAY ),interval -1 week)
                        and userId not in (select userId from uuch_waybill where dateCreated<date_add(curdate(),interval -1 week) GROUP BY userId )";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 130: {
                     $sql = "SELECT SUM(CASE WHEN isVolume=1 THEN volumeWeight ELSE productWeight+bagWeight END)/1000 FROM uuch_waybill where status >=1 and
                        DATE_FORMAT(dateCreated, '%Y-%m-%e')=  date_add(DATE_ADD( CURDATE( ) , INTERVAL -1 DAY ),interval -1 month)
                        and userId not in (select userId from uuch_waybill where dateCreated<date_add(curdate(),interval -1 month) GROUP BY userId)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }
           case 22: {
                    $sql = "SELECT SUM(CASE WHEN isVolume=1 THEN volumeWeight ELSE productWeight+bagWeight END)/1000 FROM `uuch_waybill` 
                    where status >=1 and DATE_FORMAT(dateCreated  , '%Y-%m-%e')=  date_add(curdate(),interval -2 day)
                    and userId in (select userId from uuch_waybill where dateCreated<date_add(curdate(),interval -2 day) GROUP BY userId )";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 21: {
                    $sql = "SELECT SUM(CASE WHEN isVolume=1 THEN volumeWeight ELSE productWeight+bagWeight END)/1000 FROM `uuch_waybill` 
                    where status >=1 and DATE_FORMAT(dateCreated  , '%Y-%m-%e')=  date_add(curdate(),interval -1 day)
                    and userId  in (select userId from uuch_waybill where dateCreated<date_add(curdate(),interval -1 day) GROUP BY userId )";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 20: {
                    $sql = "SELECT SUM(CASE WHEN isVolume=1 THEN volumeWeight ELSE productWeight+bagWeight END)/1000 FROM `uuch_waybill` 
                    where status >=1 and DATE_FORMAT(dateCreated  , '%Y-%m-%e')=   curdate()
                    and userId  in (select userId from uuch_waybill where dateCreated<curdate() GROUP BY userId )";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 29: {
                    $sql = "SELECT SUM(CASE WHEN isVolume=1 THEN volumeWeight ELSE productWeight+bagWeight END)/7000 FROM `uuch_waybill` 
                 where status >=1 and dateCreated <=date_add(curdate(),interval -2 day) and dateCreated >date_add(curdate(),interval -9 day) 
                 and userId  in (select userId from uuch_waybill where dateCreated<date_add(curdate(),interval -9 day) GROUP BY userId )";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 28: {
                    $sql = "SELECT SUM(CASE WHEN isVolume=1 THEN volumeWeight ELSE productWeight+bagWeight END)/7000 FROM `uuch_waybill` 
                 where status >=1 and dateCreated <=date_add(curdate(),interval -1 day) and dateCreated >date_add(curdate(),interval -8 day)  
                 and userId  in (select userId from uuch_waybill where dateCreated<date_add(curdate(),interval -8 day) GROUP BY userId )";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 27: {
                    $sql = "SELECT SUM(CASE WHEN isVolume=1 THEN volumeWeight ELSE productWeight+bagWeight END)/7000 FROM `uuch_waybill` 
                 where status >=1 and dateCreated <=curdate() and dateCreated >date_add(curdate(),interval -7 day) 
                 and userId  in (select userId from uuch_waybill where dateCreated<date_add(curdate(),interval -7 day) GROUP BY userId )";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case -27: {
                    $sql = "SELECT SUM(CASE WHEN isVolume=1 THEN volumeWeight ELSE productWeight+bagWeight END)/1000 FROM uuch_waybill where status >=1 and
                        DATE_FORMAT(dateCreated, '%Y-%m-%e')=  date_add(DATE_ADD( CURDATE( ) , INTERVAL -1 DAY ),interval -1 week)
                        and userId  in (select userId from uuch_waybill where dateCreated<date_add(curdate(),interval -1 week) GROUP BY userId )";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 230: {
                     $sql = "SELECT SUM(CASE WHEN isVolume=1 THEN volumeWeight ELSE productWeight+bagWeight END)/1000 FROM uuch_waybill where status >=1 and
                        DATE_FORMAT(dateCreated, '%Y-%m-%e')=  date_add(DATE_ADD( CURDATE( ) , INTERVAL -1 DAY ),interval -1 month)
                        and userId  in (select userId from uuch_waybill where dateCreated<date_add(curdate(),interval -1 month) GROUP BY userId)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }
        }
    }

    public function getExpressOrderCount($day) {
        $db = $this->getAdapter();
        switch ($day) {
            case 2: {
                    $sql = "select count(id) orderNum  from uuch_waybill where status >=1 and DATE_FORMAT(dateCreated  , '%Y-%m-%e')=  date_add(curdate(),interval -2 day)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 1: {
                    $sql = "select count(id) orderNum  from uuch_waybill where status >=1 and DATE_FORMAT(dateCreated  , '%Y-%m-%e')=  date_add(curdate(),interval -1 day)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 0: {
                    $sql = "select count(id) orderNum  from uuch_waybill where status >=1 and DATE_FORMAT(dateCreated  , '%Y-%m-%e')=  curdate()";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 9: {
                    $sql = "select count(*)/7 from uuch_waybill where status >=1 and dateCreated <=date_add(curdate(),interval -2 day) and 
	dateCreated  >date_add(curdate(),interval -9 day) ";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 8: {
                    $sql = "select  count(*)/7 from uuch_waybill where status >=1 and dateCreated <=date_add(curdate(),interval -1 day) and 
	dateCreated  >date_add(curdate(),interval -8 day)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 7: {
                    $sql = "select count(*)/7 from uuch_waybill 
                        where status >=1 and dateCreated <=curdate() and 	
                        dateCreated  >date_add(curdate(),interval -7 day)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case -7: {
                    $sql = "select count(id) orderNum  from uuch_waybill
                    where status >=1 and DATE_FORMAT(datecreated , '%Y-%m-%e')=  date_add(DATE_ADD( CURDATE( ) , INTERVAL -1
DAY ),interval -1 week)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 30: {
                    $sql = "select count(id) orderNum  from uuch_waybill
                    where status >=1 and DATE_FORMAT(datecreated , '%Y-%m-%e')=  date_add(DATE_ADD( CURDATE( ) , INTERVAL -1
DAY ),interval -1 month)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }
           case 12: {
                    $sql = "select count(id) orderNum  from uuch_waybill where status >=1 and DATE_FORMAT(dateCreated  , '%Y-%m-%e')=  date_add(curdate(),interval -2 day)
                        and userId not in (SELECT userId from uuch_waybill where status>=1 and dateCreated < date_add(curdate(),interval -2 day) GROUP BY userid) ";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 11: {
                    $sql = "select count(id) orderNum  from uuch_waybill where status >=1 and DATE_FORMAT(dateCreated  , '%Y-%m-%e')=  date_add(curdate(),interval -1 day)
                        and userId not in (SELECT userId from uuch_waybill where status>=1 and dateCreated < date_add(curdate(),interval -1 day) GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 10: {
                    $sql = "select count(id) orderNum  from uuch_waybill where status >=1 and DATE_FORMAT(dateCreated  , '%Y-%m-%e')=  curdate()
                        and userId not in (SELECT userId from uuch_waybill where status>=1 and dateCreated < curdate() GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 19: {
                    $sql = "select count(*)/7 from uuch_waybill where status >=1 and dateCreated <=date_add(curdate(),interval -2 day) and dateCreated  >date_add(curdate(),interval -9 day) 
                        and userId not in (SELECT userId from uuch_waybill where status>=1 and dateCreated < date_add(curdate(),interval -9 day) GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 18: {
                    $sql = "select  count(*)/7 from uuch_waybill where status >=1 and dateCreated <=date_add(curdate(),interval -1 day) and dateCreated  >date_add(curdate(),interval -8 day)
                        and userId not in (SELECT userId from uuch_waybill where status>=1 and dateCreated < date_add(curdate(),interval -8 day) GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 17: {
                    $sql = "select count(*)/7 from uuch_waybill where status >=1 and dateCreated <=curdate() and dateCreated  >date_add(curdate(),interval -7 day)
                        and userId not in (SELECT userId from uuch_waybill where status>=1 and dateCreated < date_add(curdate(),interval -7 day) GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case -17: {
                    $sql = "select count(id) orderNum  from uuch_waybill where status >=1 and DATE_FORMAT(datecreated , '%Y-%m-%e')=  date_add(DATE_ADD( CURDATE( ) , INTERVAL -1 DAY ),interval -1 week)
                        and userId not in (SELECT userId from uuch_waybill where status>=1 and dateCreated < date_add(DATE_ADD( CURDATE( ) , INTERVAL -1 DAY ),interval -1 week) GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 130: {
                    $sql = "select count(id) orderNum  from uuch_waybill where status >=1 and DATE_FORMAT(datecreated , '%Y-%m-%e')=  date_add(DATE_ADD( CURDATE( ) , INTERVAL -1 DAY ),interval -1 month)
                        and userId not in (SELECT userId from uuch_waybill where status>=1 and dateCreated < date_add(DATE_ADD( CURDATE( ) , INTERVAL -1 DAY ),interval -1 month) GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }
           case 22: {
                    $sql = "select count(id) orderNum  from uuch_waybill where status >=1 and DATE_FORMAT(dateCreated  , '%Y-%m-%e')=  date_add(curdate(),interval -2 day)
                        and userId in (SELECT userId from uuch_waybill where status>=1 and dateCreated < date_add(curdate(),interval -2 day) GROUP BY userid) ";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 21: {
                    $sql = "select count(id) orderNum  from uuch_waybill where status >=1 and DATE_FORMAT(dateCreated  , '%Y-%m-%e')=  date_add(curdate(),interval -1 day)
                        and userId in (SELECT userId from uuch_waybill where status>=1 and dateCreated < date_add(curdate(),interval -1 day) GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 20: {
                    $sql = "select count(id) orderNum  from uuch_waybill where status >=1 and DATE_FORMAT(dateCreated  , '%Y-%m-%e')=  curdate()
                        and userId in (SELECT userId from uuch_waybill where status>=1 and dateCreated < curdate() GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 29: {
                    $sql = "select count(*)/7 from uuch_waybill where status >=1 and dateCreated <=date_add(curdate(),interval -2 day) and dateCreated  >date_add(curdate(),interval -9 day) 
                        and userId in (SELECT userId from uuch_waybill where status>=1 and dateCreated < date_add(curdate(),interval -9 day) GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 28: {
                    $sql = "select  count(*)/7 from uuch_waybill where status >=1 and dateCreated <=date_add(curdate(),interval -1 day) and dateCreated  >date_add(curdate(),interval -8 day)
                        and userId in (SELECT userId from uuch_waybill where status>=1 and dateCreated < date_add(curdate(),interval -8 day) GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 27: {
                    $sql = "select count(*)/7 from uuch_waybill where status >=1 and dateCreated <=curdate() and dateCreated  >date_add(curdate(),interval -7 day)
                        and userId in (SELECT userId from uuch_waybill where status>=1 and dateCreated < date_add(curdate(),interval -7 day) GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case -27: {
                    $sql = "select count(id) orderNum  from uuch_waybill where status >=1 and DATE_FORMAT(datecreated , '%Y-%m-%e')=  date_add(DATE_ADD( CURDATE( ) , INTERVAL -1 DAY ),interval -1 week)
                        and userId in (SELECT userId from uuch_waybill where status>=1 and dateCreated < date_add(DATE_ADD( CURDATE( ) , INTERVAL -1 DAY ),interval -1 week) GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 230: {
                    $sql = "select count(id) orderNum  from uuch_waybill where status >=1 and DATE_FORMAT(datecreated , '%Y-%m-%e')=  date_add(DATE_ADD( CURDATE( ) , INTERVAL -1 DAY ),interval -1 month)
                        and userId in (SELECT userId from uuch_waybill where status>=1 and dateCreated < date_add(DATE_ADD( CURDATE( ) , INTERVAL -1 DAY ),interval -1 month) GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }
        }
    }

    public function getExpressOrderPriceCount($day) {
        $db = $this->getAdapter();
        switch ($day) {
            case 2: {
                    $sql = "select sum(SHIPMONEY)  from uuch_waybill where status >=1 and DATE_FORMAT(dateCreated  , '%Y-%m-%e')=  date_add(curdate(),interval -2 day)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 1: {
                    $sql = "select sum(SHIPMONEY) from uuch_waybill where status >=1
                        and DATE_FORMAT(dateCreated  , '%Y-%m-%e')=  date_add(curdate(),interval -1 day)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 0: {
                    $sql = "select sum(SHIPMONEY)  from uuch_waybill where status >=1
                        and DATE_FORMAT(dateCreated  , '%Y-%m-%e')=  curdate()";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 9: {
                    $sql = "select sum(SHIPMONEY)/7 from uuch_waybill where status >=1
                            and dateCreated <=date_add(curdate(),interval -2 day) and 
	dateCreated  >date_add(curdate(),interval -9 day) ";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 8: {
                    $sql = "select sum(SHIPMONEY)/7 from uuch_waybill where status >=1
                        and dateCreated <=date_add(curdate(),interval -1 day) and 
	dateCreated  >date_add(curdate(),interval -8 day)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 7: {
                    $sql = "select sum(SHIPMONEY)/7 from uuch_waybill 
                        where status >=1 and dateCreated <=curdate() and 	
                        dateCreated  >date_add(curdate(),interval -7 day)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case -7: {
                    $sql = "select sum(SHIPMONEY) from uuch_waybill
                    where status >=1 and DATE_FORMAT(datecreated , '%Y-%m-%e')= DATE_ADD(DATE_ADD( CURDATE( ) , INTERVAL -1
DAY ) , INTERVAL -1 week )";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 30: {
                    $sql = "select sum(SHIPMONEY) from uuch_waybill
                    where status >=1 and DATE_FORMAT(datecreated , '%Y-%m-%e')=  date_add(DATE_ADD( CURDATE( ) , INTERVAL -1
DAY ),interval -1 month)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }
            case 12: {
                    $sql = "select sum(SHIPMONEY)  from uuch_waybill where status >=1 and DATE_FORMAT(dateCreated  , '%Y-%m-%e')=  date_add(curdate(),interval -2 day)
                         and userId not in (SELECT userId from uuch_waybill where status>=1 and dateCreated < date_add(curdate(),interval -2 day) GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 11: {
                    $sql = "select sum(SHIPMONEY) from uuch_waybill where status >=1 and DATE_FORMAT(dateCreated  , '%Y-%m-%e')=  date_add(curdate(),interval -1 day)
                        and userId not in (SELECT userId from uuch_waybill where status>=1 and dateCreated < date_add(curdate(),interval -1 day) GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 10: {
                    $sql = "select sum(SHIPMONEY)  from uuch_waybill where status >=1 and DATE_FORMAT(dateCreated  , '%Y-%m-%e')=  curdate()
                        and userId not in (SELECT userId from uuch_waybill where status>=1 and dateCreated < curdate() GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 19: {
                    $sql = "select sum(SHIPMONEY)/7 from uuch_waybill where status >=1 and dateCreated <=date_add(curdate(),interval -2 day) and dateCreated  >date_add(curdate(),interval -9 day) 
                        and userId not in (SELECT userId from uuch_waybill where status>=1 and dateCreated < date_add(curdate(),interval -9 day) GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 18: {
                    $sql = "select sum(SHIPMONEY)/7 from uuch_waybill where status >=1 and dateCreated <=date_add(curdate(),interval -1 day) and dateCreated  >date_add(curdate(),interval -8 day)
                        and userId not in (SELECT userId from uuch_waybill where status>=1 and dateCreated < date_add(curdate(),interval -8 day) GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 17: {
                    $sql = "select sum(SHIPMONEY)/7 from uuch_waybill where status >=1 and dateCreated <=curdate() and dateCreated  >date_add(curdate(),interval -7 day)
                        and userId not in (SELECT userId from uuch_waybill where status>=1 and dateCreated < date_add(curdate(),interval -7 day) GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case -17: {
                    $sql = "select sum(SHIPMONEY) from uuch_waybill where status >=1 and DATE_FORMAT(datecreated , '%Y-%m-%e')= DATE_ADD(DATE_ADD( CURDATE( ) , INTERVAL -1 DAY ) , INTERVAL -1 week )
                        and userId not in (SELECT userId from uuch_waybill where status>=1 and dateCreated < DATE_ADD(DATE_ADD( CURDATE( ) , INTERVAL -1 DAY ) , INTERVAL -1 week ) GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 130: {
                    $sql = "select sum(SHIPMONEY) from uuch_waybill where status >=1 and DATE_FORMAT(datecreated , '%Y-%m-%e')=  date_add(DATE_ADD( CURDATE( ) , INTERVAL -1 DAY ),interval -1 month)
                        and userId not in (SELECT userId from uuch_waybill where status>=1 and dateCreated < DATE_ADD(DATE_ADD( CURDATE( ) , INTERVAL -1 DAY ) , INTERVAL -1 month ) GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }
            case 22: {
                    $sql = "select sum(SHIPMONEY)  from uuch_waybill where status >=1 and DATE_FORMAT(dateCreated  , '%Y-%m-%e')=  date_add(curdate(),interval -2 day)
                         and userId in (SELECT userId from uuch_waybill where status>=1 and dateCreated < date_add(curdate(),interval -2 day) GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 21: {
                    $sql = "select sum(SHIPMONEY) from uuch_waybill where status >=1 and DATE_FORMAT(dateCreated  , '%Y-%m-%e')=  date_add(curdate(),interval -1 day)
                        and userId in (SELECT userId from uuch_waybill where status>=1 and dateCreated < date_add(curdate(),interval -1 day) GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 20: {
                    $sql = "select sum(SHIPMONEY)  from uuch_waybill where status >=1 and DATE_FORMAT(dateCreated  , '%Y-%m-%e')=  curdate()
                        and userId in (SELECT userId from uuch_waybill where status>=1 and dateCreated < curdate() GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 29: {
                    $sql = "select sum(SHIPMONEY)/7 from uuch_waybill where status >=1 and dateCreated <=date_add(curdate(),interval -2 day) and dateCreated  >date_add(curdate(),interval -9 day) 
                        and userId in (SELECT userId from uuch_waybill where status>=1 and dateCreated < date_add(curdate(),interval -9 day) GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 28: {
                    $sql = "select sum(SHIPMONEY)/7 from uuch_waybill where status >=1 and dateCreated <=date_add(curdate(),interval -1 day) and dateCreated  >date_add(curdate(),interval -8 day)
                        and userId in (SELECT userId from uuch_waybill where status>=1 and dateCreated < date_add(curdate(),interval -8 day) GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 27: {
                    $sql = "select sum(SHIPMONEY)/7 from uuch_waybill where status >=1 and dateCreated <=curdate() and dateCreated  >date_add(curdate(),interval -7 day)
                        and userId in (SELECT userId from uuch_waybill where status>=1 and dateCreated < date_add(curdate(),interval -7 day) GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case -27: {
                    $sql = "select sum(SHIPMONEY) from uuch_waybill where status >=1 and DATE_FORMAT(datecreated , '%Y-%m-%e')= DATE_ADD(DATE_ADD( CURDATE( ) , INTERVAL -1 DAY ) , INTERVAL -1 week )
                        and userId in (SELECT userId from uuch_waybill where status>=1 and dateCreated < DATE_ADD(DATE_ADD( CURDATE( ) , INTERVAL -1 DAY ) , INTERVAL -1 week ) GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 230: {
                    $sql = "select sum(SHIPMONEY) from uuch_waybill where status >=1 and DATE_FORMAT(datecreated , '%Y-%m-%e')=  date_add(DATE_ADD( CURDATE( ) , INTERVAL -1 DAY ),interval -1 month)
                        and userId in (SELECT userId from uuch_waybill where status>=1 and dateCreated < date_add(DATE_ADD( CURDATE( ) , INTERVAL -1 DAY ),interval -1 month) GROUP BY userid)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }
        }
    }

    public function getStoreWeightCount($day)
    {
        $db = $this->getAdapter();

        switch ($day) {
            case 0: {
                    $sql = "select sum(weight)/1000 from uuch_storeitem where  DATE_FORMAT(dateInStore  , '%Y-%m-%e')=  curdate()";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }

            case 1: {
                    $sql = "select sum(weight)/1000 from uuch_storeitem where DATE_FORMAT(dateInStore  , '%Y-%m-%e')=  date_add(curdate(),interval -1 day)";
                    $result = $db->query($sql);
                    return $result->fetchColumn();
                }
        }
    }
}

?>
